package com.wj.dubbo.utils;

import java.util.List;

public class PageUtils {

	/**
	 * 列表内存分页
	 * @param aList
	 * @param pageSize
	 * @param currentPage
	 * @return
	 */
	public static <T> List<T> pageList(List<T> aList, int pageSize, int currentPage){
		if(null == aList || aList.isEmpty()){
			return aList;
		}
		int start = 0;
		int end = 0;
		int total = aList.size();
		start = currentPage <= 0 ? 0 : currentPage * pageSize;
		//确认起始索引
		start = start > total ? total : start;
		
		end = start + pageSize;
		end = end > total ? total : end;
		return aList.subList(start, end);
	}
	
}
